#*************************************************************
# extract_time_series.py
# 
# Extracts time series at a set of points and writes
# out text file.  Replacement for using wgrib2 
# which relied on cnvgrib which proved unlreliable.
# May also allow more flexible control over interpolation
# and derived variables.
#
# Could eventually become the basis for visualisation as well. 
# replacing Ncl scripts with PyNGL.
#
# TODO
# Check command-line args
# Resolve circularity - currently uses wrftools 
# to read time series, whereas wrftools is higer-level
#
#**************************************************************

import Nio
import sys
import wrftools

def main():
    # to do - check args    
    extract_time_series(sys.argv[1], sys.argv[2], sys.argv[3])


def extract_time_series(grb_file, loc_file, out_dir):
    dataset   = Nio.open_file(grb_file, 'r')
    locations = wrftools.read_locations(loc_file)
    dataset.close() 


if __name__ == '__main__':
    main()
